<template>
  <v-data-table
    :headers="headers"
    :items="desserts"
    :items-per-page="5"
    class="elevation-1"
  >
    <template v-slot:[`item.actions`]="{ item }">
      <v-btn color="blue" @click="checkReport(item)"> 查看报告 </v-btn>
    </template>
    </v-data-table>
</template>
<script>
export default {
  data() {
    return {
      headers: [
        {
          text: "任务ID",
          align: "start",
          sortable: false,
          value: "id",
        },
        { text: "任务描述", value: "remark" },
        { text: "创建时间", value: "create_at", sortable: true},
        { text: "报告地址", value: "report" },
        { text: "备注", value: "actions", sortable: false },
      ],
      desserts: [

      ],
    };
  },
  created() {
  this.getTaskList();
  },

  methods: {
    getTaskList(){
      console.log("查找任务")
      this.$api.task.getTask().then((result) => {
        console.log(result)
         this.desserts = result["data"]["msg"]["data"]
      }).catch((err) => {
        console.log(err)
      });
    },
    checkReport(item){
      console.log("打开报告")
      window.open(item.report)
    }
  }
};
</script>